#include "vector.hpp"
#include "ray.hpp"
#include "sphere.hpp"
#include "plane.hpp"
#include "scene.hpp"
#include "raytracer.hpp"
#include "grid.hpp"
#include "light.hpp"
#include "color.hpp"
#include "material.hpp"
#include "object.hpp"
#include "photontracer.hpp"
#include "output.hpp"

#define ALTURA 800
#define LARGURA 800

double x=0.0f,y=0.0,z=1.0;

Material* m1 = new Material(Color(1.0,0.0,0.0),Color(1.0,0.0,0.0),Color(1.0,1.0,1.0),50);
Material* m2 = new Material(Color(0.0,1.0,0.0),Color(0.0,1.0,0.0),Color(1.0,1.0,1.0),50);
Material* m3 = new Material(Color(0.0,0.0,1.0),Color(0.0,0.0,1.0),Color(1.0,1.0,1.0),50);
Material* m4 = new Material(Color(0.01,0.01,0.01),Color(0.2,0.2,0.2),Color(1,1,1),50);

Material* m5 = new Material(Color(0.0,0.0,0.5),Color(0.0,0.0,0.5),Color(1.0,1.0,1.0),100);
Material* m6 = new Material(Color(0.0,0.0,0.0),Color(0.0,0.0,0.0),Color(1.0,1.0,1.0),50);

Object* e1 = new Sphere(m1,Vector(0.0,1.0,-1.5),0.5);
Object* e2 = new Sphere(m2,Vector(1.0,0.5,-1.5),0.5);
Object* e3 = new Sphere(m3,Vector(-1.0,0.5,-1.5),0.5);
Object* e4 = new Sphere(m4,Vector(0.0,0.0,-4.0),1.5);

Object* p1 = new Plane(m6,Vector(0.0,0.0,-2.0),Vector(0.0,0.0,1.0));
Object* p2 = new Plane(m6,Vector(0.0,0.0,2.0),Vector(0.0,0.0,-1.0));
Object* p3 = new Plane(m6,Vector(2.0,0.0,0.0),Vector(-1.0,0.0,0.0));
Object* p4 = new Plane(m6,Vector(-2.0,0.0,0.0),Vector(1.0,0.0,0.0));
Object* p5 = new Plane(m6,Vector(0.0,2.0,0.0),Vector(0.0,-1.0,0.0));
Object* p6 = new Plane(m6,Vector(0.0,-1.0,0.0),Vector(0.0,1.0,0.0));

Light* luz1 = new Light(Vector(0.0,0.0,2.0),Vector(0.0,1.0,1.0),
		Color(1.0,1.0,1.0),
		Color(1.0,1.0,1.0),
		Color(1.0,1.0,1.0)
		);
Light* luz2 = new Light(Vector(0.0,2.0,0.0),Vector(1.0,0.0,1.0),
		Color(1.0,1.0,1.0),
		Color(1.0,1.0,1.0),
		Color(1.0,1.0,1.0)
		);

Scene* c = new Scene(Color(0.0,0.0,0.0),0.5);

Grid* g = new Grid(Vector(1.0,0.0,0.0),Vector(0.0,1.0,0.0),Vector(0.0,0.0,0.0));

Raytracer* r = new Raytracer(c,g,Vector(0.0,0.0,2.0),Vector(0.0,1.0,0.0),ALTURA,LARGURA,2);

Photontracer* p = new Photontracer(c,2);


int main(int argc, char** argv) {
	Output* file;
	c->set_attenuation(0.01,0.01,1.0);
	c->add_light(luz1);
	c->add_object(e1);
	//c->add_object(e2);
	//c->add_object(e3);
	/*c->add_object(e4);*/
	/*c->add_object(p1);
	c->add_object(p2);
	c->add_object(p3);
	c->add_object(p4);
	c->add_object(p5);*/
	//c->add_object(p6);
//	c->add_light(luz2);
	/*Sphere* esf;
	for(int i=0;i < 3;i++) {
		double x = -1+(((double) i));
		for(int j =0;j<3;j++) {
			double y = -1+(((double) j));
			esf = new Sphere(m2,Vector(0.5*x,0.5*y,-1.0),0.25);
			if(i==1 && j ==1) { 
				esf = new Sphere(m1,Vector(0.5*x,0.5*y,-2.0),0.75);
			}
			if(i%2 == 0 && j%2 == 0)
				esf = new Sphere(m3,Vector(0.5*x,0.5*y,-1.0),0.25);
			c->add_object(esf);
		}
	}*/
	file = r->render();
	file->save_file("teste.tga");
	p->trace();
} 















